package net.esj.basic.dao.ann.criterion;

import java.util.Date;

import net.esj.basic.utils.DateFormat;

public class PrototypeCriterion extends PropertyCriterion<Object> {

	public PrototypeCriterion(Object value) {
		super(value);
	}

	@Override
	public String toSql() {
		return generateSQLValue(value.getClass(), value);
	}

	public static final String generateSQLValue(Class clazz,Object value){
		if(clazz == String.class){
			return "'"+value.toString()+"'";
		}else if(clazz == Date.class){
			return DateFormat.formateDateTime((Date) value, DateFormat.DEFAULT_DATETIME_FORMAT_SEC);
		}else{
			return value.toString();
		}
	}
}
